package com.zzz.controller;

import com.aaa.entity.*;
import com.aaa.util.PayUtils;
import com.aaa.vo.Result;
import com.zzz.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ：zxw
 * @date ：Created in 2023/3/9 19:40
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("good/operate")
public class OperateController {

    @Autowired
    private UCommentService uCommentService;

    @Autowired
    private OCartService oCartService;

    @Autowired
    private UCollectionService uCollectionService;

    @Autowired
    private OOrderService oOrderService;

    @Autowired
    private OPayLogService oPayLogService;

    @Autowired
    private GBrandService gBrandService;

    @Autowired
    private GSortService gSortService;

    @Autowired
    private GDepositService gDepositService;

    //添加评论
    @RequestMapping("addComment")
    public Result addComment(@RequestBody UComment uComment){
        Result result = uCommentService.addComment(uComment);
        return result;
    }

    //添加图片
    @RequestMapping("upload01")
    public Result insertFile(@RequestBody MultipartFile file){
        return uCommentService.insert(file);
    }

    //删除评论
    @RequestMapping("deleteById")
    public Result deleteById(String id){
        return uCommentService.delete(id);
    }

    //查询要修改的评论
    @RequestMapping("getCommentById/{id}")
    public Result getCommentById(@PathVariable String id){
        Result commentById = uCommentService.getCommentById(id);
        return commentById;
    }

    //修改评论
    @RequestMapping("updateComment")
    public Result updateComment(@RequestBody UComment uComment){
       return uCommentService.updateComment(uComment);
    }

    //添加到购物车
    @RequestMapping("addCart")
    public Result addCart(@RequestBody OCart oCart){
        Result result = oCartService.addCart(oCart);
        return result;
    }

    //收藏或取消收藏状态
    @RequestMapping("changeCollectionStatus")
    public Result changeCollectionStatus(@RequestBody UCollection uCollection){
        return uCollectionService.changeCollectionStatus(uCollection);
    }

    //关注或取关店铺
    @RequestMapping("changeGuanzhu")
    public Result changeGuanzhu(@RequestBody UCollection uCollection){
        return uCollectionService.changeGuanzhu(uCollection);
    }

    //生成支付宝二维码加支付宝支付
    @PostMapping("buyNowAli")
    public Result buyNowAli(@RequestBody PayUtils payUtils){
        Result payInfo = oOrderService.getPayInfo(payUtils);
        return payInfo;
    }

    //生成微信二维码加微信支付
    @PostMapping("buyNowWx")
    public Result buyNowWx(@RequestBody PayUtils payUtils){
        Result result = oOrderService.buyNow(payUtils);
        return result;
    }

    //生成订单
    @RequestMapping("settlement")
    public Result settlement(@RequestBody OOrder oOrder){
        Result settlement = oOrderService.settlement(oOrder);
        return settlement;
    }

    //添加品牌
     @RequestMapping("addBrand")
    public Result addBrand(@RequestBody GBrand brand){
         Result result = gBrandService.addBrand(brand);
         return result;
     }

     //添加类别
    @RequestMapping("addSort")
    public Result addSort(@RequestBody GSort sort){
        Result result = gSortService.addSort(sort);
        return result;
    }

    //添加存储方式
    @RequestMapping("addDeposit")
    public Result addDeposit(@RequestBody GDeposit deposit){
        Result result = gDepositService.addDeposit(deposit);
        return result;
    }

}

